package demo6;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Demo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context
                = new AnnotationConfigApplicationContext("demo6");
        /*
           Spring容器默认管理对象为单例，即：容器内部仅创建一个对象
           多次获取始终返回同一个对象
         */
        Person person1 = context.getBean(Person.class);
        Person person2 = context.getBean(Person.class);
        System.out.println("p1="+person1);
        System.out.println("p2="+person2);
        System.out.println(person1 == person2);
    }
}
